new Vue({
  el: '#app',
  data() {
    return {
      form: {
        page: 1,			//页数
        limit: 10,		//每页数据条数
        Article_Name: "",
        Enterprise_Info_SerialNumber: $.cookie('enterprise')
      },
      tableData: [],
      //表格数据
      total: 1,
    }
  },
  mounted() {
    this.getList(this.form)
  },
  methods: {
    onSerach() {				//查询方法
      this.getList(this.form)
    },
    handleSizeChange(val) {
      this.form.page = 1;
      this.form.limit = val;
      this.getList(this.form)
    },
    handleCurrentChange(val) {
      this.form.page = val;
      this.getList(this.form)
    },
    getList(data) {
      let _this = this
      $.ajax({
        type: 'POST',
        data,
        url: DomainName + '/getDealerUnitPriceAction?token=' + $.cookie("token"),
        success: function (data) {
          _this.tableData = data.tableData;
          _this.total = Number(data.limit);
          console.log(_this.tableData)
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      });
    },
    addEnterprise() {
      window.location.href = './Add.html'
    },
    editMember(Dealer_Unit_Price_SerialNumber) {
      sessionStorage.setItem("Dealer_Unit_Price_SerialNumber", Dealer_Unit_Price_SerialNumber)
      window.location.href = './Edit.html?Dealer_Unit_Price_SerialNumber=' + Dealer_Unit_Price_SerialNumber
    },
    deletMember(Dealer_Unit_Price_SerialNumber) {
      this.$confirm('此操作将删除该价格单, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        $.ajax({
          type: 'POST',
          data: {
            TableName: 'dealer_unitprice',
            Primary_Key: Dealer_Unit_Price_SerialNumber,
            Primary_Key_Name: 'Dealer_Unit_Price_SerialNumber',
          },
          url: DomainName + '/DeleteAction?token=' + $.cookie("token"),
          success: (res) => {
            if (res.Status == 'success') {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getList(this.form);
            } else {
              this.$message({
                type: 'error',
                message: '提交失败，请重试!'
              });
            }
          },
          complete: function (XMLHttpRequest) {
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
            }
          },
          dataType: "json"
        });
      }).catch(() => { });
    },
  },
})